package com.digitalchina.lxnsy.xml;

import android.content.Context;

import com.digitalchina.lxnsy.entity.UserVO;
import com.digitalchina.lxnsy.toolkit.SharedPreferencesUtil;


/**
 * ================================================
 * 项目名称：bigdata
 * 类描述：
 * 包名：com.digitalchina.bigdata.xml
 * 创建人：郑皓
 * 创建时间：2016/6/1 14:24
 * 修改备注：
 * ================================================
 */
public class UserXML {


    public static final String XML_NAME_USER = "User";

//    "useraccid": "f749e0b3-ffc1-4c92-adb2-02f1f005d0c6",
//    "usermobilephone": "15810800621",
//    "userimg": "f6c5bb38-f3a1-4c3b-8646-ed6344a00874",
//    "userType": "10",
//    "id": "ba4f894d-0400-4dc7-9f79-bbdbc34f0b74",
//    "useraccName": "test1234",
//    "userName": "大魔王"

    public static final String ID = "id";
    public static final String USERACCID = "useraccid";
    public static final String TRUENAME = "trueName";
    public static final String USERMOBILEPHONE = "usermobilephone";
    public static final String USERIMG = "userimg";
    public static final String LOGIN = "LOGIN";
    public static final String LOGINNAME = "loginName";
    public static final String SECURELOGIN = "secureLogin";
    public static final String USERTYPE = "userType";
    public static final String USERACCNAME = "useraccName";
    public static final String USERNAME = "userName";
    public static final String LOGINPASSWORD = "loginPassword";
    public static final String LOGINACCOUNT = "loginAccount";
    public static final String TODAYLOGIN = "todayLogin";
    public static final String REGISTERMONEY = "registerMoney";
    public static final String INVITECODE = "inviteCode";
    public static final String MSGTIME = "msgTime";
    public static final String ISHAVEMYEXPERT = "isHaveMyExpert";// 是否有专家

    public static final String USER_DEFAULT_VALUE = "";

    // 用户是否已经登录 1=登录 0=未登录
    public static final String USER_IS_LOGIN = "isLogin";
    public static final String USER_IS_GUIDE = "isGuide";
    public static final String USER_IS_LOGIN_VALUE = "1";
    public static final String AGREEMENT = "agreement";

//    public static final String USER_NOT_LOGIN_VALUE = "0";

    public static void setUserVO(Context ctx, UserVO userVO) {
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, ID, userVO.getId());
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, USERACCID, userVO.getUseraccid());
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, TRUENAME, userVO.getTrueName());
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, LOGINNAME, userVO.getLoginName());
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, USERMOBILEPHONE, userVO.getUsermobilephone());
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, USERIMG, userVO.getUserimg());
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, LOGIN, userVO.getLOGIN());
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, SECURELOGIN, userVO.getSecureLogin());
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, USERACCNAME, userVO.getUseraccName());
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, USERNAME, userVO.getUserName());
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, USERTYPE, userVO.getUserType());
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, LOGINPASSWORD, userVO.getInitialPassword());
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, INVITECODE, userVO.getInviteCode());
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, ISHAVEMYEXPERT, userVO.isIsHaveMyExpert());

        AdminXML.setUserAccId(ctx, userVO.getUseraccid());
        AdminXML.setUserType(ctx, "0");
    }


    /**
     * 根据传递的key获取对应的value
     *
     * @param ctx
     * @param key
     * @param defaultValue
     * @return
     */
    public static String getVal(Context ctx, String key, String defaultValue) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_USER, key, defaultValue);
    }

    /**
     * 根据传递的key存储响应的value
     *
     * @param ctx
     * @param key
     * @param value
     */
    public static void setVal(Context ctx, String key, String value) {
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, key, value);
    }

    /**
     * 设置是否点击过协议
     */
    public static void setAgreement(Context ctx) {
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, AGREEMENT, USER_IS_LOGIN_VALUE);
    }
    public static String getAgreement(Context ctx) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_USER, AGREEMENT, USER_DEFAULT_VALUE);
    }

    /**
     * 设置当天登录的日期
     *
     * @param ctx
     * @param data
     */
    public static void setTodayLogin(Context ctx, String data) {
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, TODAYLOGIN, data);
    }


    /**
     * 获取当天登录的日期
     *
     * @param ctx
     * @return
     */
    public static String getTodayLogin(Context ctx) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_USER, TODAYLOGIN, USER_DEFAULT_VALUE);
    }

    /**
     * 获取用户的登录账户
     *
     * @param ctx
     * @return
     */
    public static String getLoginAccount(Context ctx) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_USER, LOGINACCOUNT, USER_DEFAULT_VALUE);
    }

    /**
     * 获取用户的登录密码
     *
     * @param ctx
     * @return
     */
    public static String getLoginPassword(Context ctx) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_USER, LOGINPASSWORD, USER_DEFAULT_VALUE);
    }

    /**
     * 设置密码
     *
     * @param ctx
     * @param password
     */
    public static void setLoginPassword(Context ctx, String password) {
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, LOGINPASSWORD, password);
    }

    /**
     * 获取用户的登录名
     *
     * @param ctx
     * @return
     */
    public static String getLoginName(Context ctx) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_USER, LOGINNAME, USER_DEFAULT_VALUE);
    }

    /**
     * 获取用户的登录名
     *
     * @param ctx
     * @return
     */
    public static String getUserType(Context ctx) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_USER, USERTYPE, USER_DEFAULT_VALUE);
    }


    /**
     * 获取用户Id
     *
     * @param ctx
     * @return
     */
    public static String getId(Context ctx) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_USER, ID, USER_DEFAULT_VALUE);
    }

    /**
     * 获取用户userId
     *
     * @param ctx
     * @return
     */
    public static String getUserId(Context ctx) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_USER, USERACCID, USER_DEFAULT_VALUE);
    }



    /**
     * 获取用户真实姓名
     *
     * @param ctx
     * @return
     */
    public static String getUserTrueName(Context ctx) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_USER, TRUENAME, USER_DEFAULT_VALUE);
    }

    /**
     * 获取用户的名
     *
     * @param ctx
     * @return
     */
    public static String getName(Context ctx) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_USER, USERNAME, USER_DEFAULT_VALUE);
    }

    /**
     * 获取LOGIN
     *
     * @param ctx
     * @return
     */
    public static String getLOGIN(Context ctx) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_USER, LOGIN, USER_DEFAULT_VALUE);
    }

    public static void setLOGIN(Context ctx, String s) {
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, LOGIN, s);
    }

    /**
     * 获取secureLogin
     *
     * @param ctx
     * @return
     */
    public static String getSecureLogin(Context ctx) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_USER, SECURELOGIN, USER_DEFAULT_VALUE);
    }

    public static void setSECURELOGIN(Context ctx, String s) {
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, SECURELOGIN, s);
    }
    /**
     * 获取用户登录状态 1=登录 0=未登录
     *
     * @param ctx
     * @return
     */
    public static String getLoginStatus(Context ctx) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_USER, USER_IS_LOGIN, USER_DEFAULT_VALUE);
    }

    /**
     * 引导图状态
     *
     * @param ctx
     * @param guideStatus 1=登录 0=未登录
     */
    public static void setGuideStatus(Context ctx, String guideStatus) {
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, USER_IS_GUIDE, guideStatus);
    }

    /**
     * 引导图状态 1=登录 0=未登录
     *
     * @param ctx
     * @return
     */
    public static String getGuideStatus(Context ctx) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_USER, USER_IS_GUIDE, USER_DEFAULT_VALUE);
    }

    /**
     * 设置用户登录状态
     *
     * @param ctx
     * @param loginStatus 1=登录 0=未登录
     */
    public static void setLoginStatus(Context ctx, String loginStatus) {
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, USER_IS_LOGIN, loginStatus);
    }

    /**
     * 设置用户userAccId
     *
     * @param ctx
     * @param userId
     */
    public static void setUserId(Context ctx, String userId) {
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, USERACCID, userId);
    }

    /**
     * 测试用 设置用户userName
     *
     * @param ctx
     * @param userName
     */
    public static void setName(Context ctx, String userName) {
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, USERNAME, userName);
    }

    /**
     * 测试用 设置用户loginName
     *
     * @param ctx
     * @param loginName
     */
    public static void setLoginName(Context ctx, String loginName) {
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, LOGINNAME, loginName);
    }


    /**
     * 测试用 设置用户登录手机号
     *
     * @param ctx
     * @param phone
     */
    public static void setMobilePhone(Context ctx, String phone) {
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, USERMOBILEPHONE, phone);
    }


    /**
     * 获取用户的mobilephone
     *
     * @param ctx
     * @return
     */
    public static String getMobilePhone(Context ctx) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_USER, USERMOBILEPHONE, USER_DEFAULT_VALUE);
    }

    /**
     * 获取用户的mobilephone
     *
     * @param ctx
     * @return
     */
    public static String getUseraccName(Context ctx) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_USER, USERACCNAME, USER_DEFAULT_VALUE);
    }


    /**
     * 获取头像路径
     */
    public static String getImagePath(Context ctx) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_USER, USERIMG, USER_DEFAULT_VALUE);
    }

    /**
     * 设置头像
     */
    public static void setImagePath(Context ctx, String imagePath) {
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, USERIMG, imagePath);
    }

    /**
     * 注册并登陆农币json
     */
    public static String getRegisterMoney(Context ctx) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_USER, REGISTERMONEY, USER_DEFAULT_VALUE);
    }

    public static void setRegisterMoney(Context ctx, String registerMoneyList) {
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, REGISTERMONEY, registerMoneyList);
    }


    public static String getInviteCode(Context ctx) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_USER, INVITECODE, USER_DEFAULT_VALUE);
    }

    public static void setInviteCode(Context ctx, String inviteCode) {
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, INVITECODE, inviteCode);
    }

    public static String getMsgTime(Context ctx) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_USER, MSGTIME, USER_DEFAULT_VALUE);
    }

    public static void setMsgTime(Context ctx, String msgTime) {
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, MSGTIME, msgTime);
    }

    public static String getIsHaveMyExpert(Context ctx) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_USER, ISHAVEMYEXPERT, USER_DEFAULT_VALUE);
    }

    public static void setIsHaveMyExpert(Context ctx, String isHaveMyExpert) {
        SharedPreferencesUtil.setValue(ctx, XML_NAME_USER, ISHAVEMYEXPERT, isHaveMyExpert);
    }
}

